<template>
    <div class="content">
        <van-popup style="height: 100%; width: 70%; background-color: #2e323b" v-model:show="show" position="left"
            class="leftcontent">
            <div class="shichang">{{ $t('市場') }}</div>
            <van-search :clearable="false" v-model="value" shape="round" background="#2e323b" :placeholder="$t('搜索')" />
            <div class="tab">
                <div @click="lefttabchange(0)" :style="{ color: lefttab === 0 ? '#f2ce3d' : '#fff' }" class="item">
                    {{ $t('自選') }}</div>
                <div @click="lefttabchange(1)" :style="{ color: lefttab === 1 ? '#f2ce3d' : '#fff' }" class="item">
                    {{ $t('USDT') }}
                </div>
            </div>
            <div class="title">
                <div class="left"> {{ $t('交易對') }}</div>
                <div class="right"> {{ $t('交易對') }}/24H{{ $t('漲跌幅') }}</div>
            </div>
            <div class="cont">
                <div class="item" v-for="item in 10">
                    <div class="left">
                        <span style="color: #fff;">BTC</span>
                        <span style="color: #556566;">/USDT</span>
                    </div>
                    <div class="right">
                        <div class="top">26794.53</div>
                        <div :style="{ color: leftnum > 0 ? '#2ebd85' : '#f5465d' }" class="btm">{{ leftnum }}%</div>
                    </div>
                </div>
            </div>
        </van-popup>
        <div class="title">
            <div @click="router.back()" class="left">
                <van-icon name="arrow-left" color="#fff" size="20px" />
            </div>
            <div @click="popShow" class="centre">
                <van-icon name="exchange" />
                <span>BTC/USDT</span>
            </div>
            <div class="right">
                <van-rate class="star" clearable color="#ffd21e" void-color="#eee" :count="1" v-model="score" />
            </div>
        </div>
        <div class="data">
            <div class="left">
                <div class="img">
                    <img class="imgitem" src="@/assets/view/b.png" alt="">
                    <img class="imgitem" style="position: absolute;left: 26px;top: 1;" src="@/assets/view/u.png" alt="">
                </div>
                <div class="num">27026.99</div>
                <div class="centi">1.02%</div>
            </div>
            <div class="right">
                <div class="item">
                    <div class="top">High</div>
                    <div class="btm">27483.57</div>
                </div>
                <div class="item">
                    <div class="top">High</div>
                    <div class="btm">27483.57</div>
                </div>
                <div class="item">
                    <div class="top">High</div>
                    <div class="btm">27483.57</div>
                </div>
                <div class="item">
                    <div class="top">High</div>
                    <div class="btm">27483.57</div>
                </div>
            </div>
        </div>
        <div class="gushi">
            <myEcharts />
        </div>
        <div class="tab">
            <van-tabs title-active-color="#f2ce3d" title-inactive-color="#fff" background="#17171a" color="#17171a"
                v-model:active="active" @click-tab="onClickTab">
                <van-tab :title="$t('最新盤口')">
                    <div class="new">
                        <div class="left">
                            <div class="top">{{ $t('買入') }}</div>
                            <div v-for="item in 50" class="item">
                                <div class="le">4.476640</div>
                                <div class="ri">27065.81</div>
                            </div>
                        </div>
                        <div class="right">
                            <div class="top">{{ $t('賣出') }}</div>
                            <div v-for="item in 50" class="item">
                                <div class="le">4.476640</div>
                                <div class="ri">27065.81</div>
                            </div>
                        </div>
                    </div>
                </van-tab>
                <van-tab :title="$t('實時成交')">
                    <div class="make">
                        <div class="title">
                            <span>{{ $t('價格') }}</span>
                            <span>{{ $t('數量') }}</span>
                            <span>{{ $t('時間') }}</span>
                        </div>
                        <div v-for="item in 50" class="item">
                            <span :style="{ color: num ? '#2ebd85' : '#f5465d' }">27050.35</span>
                            <span>0.002200</span>
                            <span style="color: #556566;">15:15:08</span>
                        </div>
                    </div>
                </van-tab>
            </van-tabs>
        </div>
        <div class="bottom">
            <div @click="goto" class="mairu">{{ $t('買入') }}</div>
            <div @click="goto" class="maichu">{{ $t('賣出') }}</div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router';
import myEcharts from '@/components/echat.vue'
const router = useRouter();

const score = ref(0)
const show = ref(false)
const value = ref('')
const leftnum = ref(0.73)
const lefttab = ref(0)
const active = ref(0)

function popShow() {
    show.value = true
}

function lefttabchange(index) {
    if (lefttab.value == index) return
    lefttab.value = index
}

function onClickTab(e) {
    console.log(e);
}

function goto() {
    router.push('/page/trade')
}

</script>

<style lang="scss" scoped>
::v-deep input {
    caret-color: #fff;
    color: #fff;
}

.van-search {
    background-color: #232830;
}

::v-deep .van-search__content {
    background: #232830;
}

.content {
    padding: 0 15px;
    width: 100%;
    box-sizing: border-box;
    background-color: #17171a;

    .leftcontent {
        .shichang {
            font-size: 22px;
            color: #fff;
            margin: 40px 0 0 15px;
        }

        .tab {
            display: flex;
            align-items: center;
            margin-top: 14px;
            padding: 0 15px;
            width: 100%;
            height: 21px;
            font-size: 15px;
            color: #fff;
            box-sizing: border-box;

            .item {
                display: flex;
                justify-content: center;
                align-items: center;
                padding: 0 5px;
            }
        }

        .title {
            width: 100%;
            height: 25px;
            padding: 0 15px;
            font-size: 12px;
            color: #d5d5d5;
            box-sizing: border-box;

            .left {}

            .right {}
        }

        .cont {
            width: 100%;
            padding: 0 15px;
            box-sizing: border-box;

            .item {
                display: flex;
                justify-content: space-between;
                align-items: center;
                width: 100%;
                height: 50px;

                .left {
                    font-size: 14px;
                }

                .right {
                    .top {
                        font-size: 14px;
                        color: #fff;
                    }

                    .btm {
                        float: right;
                        font-size: 12px;
                    }
                }
            }

        }
    }

    .title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;

        .centre {
            font-size: 13px;
            margin-top: 8px;
        }
    }

    .data {
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin-bottom: 15px;

        .left {
            width: 50%;

            .img {
                position: relative;

                .imgitem {
                    width: 32px;
                    height: 32px;
                }
            }

            .num {
                font-size: 22px;
                color: #26a07b;
            }

            .centi {
                color: #26a07b;
                font-size: 13px;
            }
        }

        .right {
            width: 50%;
            display: flex;
            flex-wrap: wrap;

            .item {
                width: 50%;
                font-size: 14px;

                .top {
                    font-size: 12px;
                    color: #d5d5d5;
                }

                .btm {
                    color: #fff;

                }
            }
        }


    }

    .gushi {
        width: 100%;
        height: 380px;
        background-color: #fff;
    }

    .tab {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        padding: 15px 0 82px 0;
        font-size: 15px;

        .new {
            display: flex;
            justify-content: space-between;
            width: 100vw;
            padding: 15px;
            height: 475px;
            background-color: #17171a;
            box-sizing: border-box;
            overflow: hidden;

            .left {
                width: 50%;
                padding-right: 10px;
                color: #d5d5d5;
                font-size: 13px;
                box-sizing: border-box;

                .item {
                    display: flex;
                    justify-content: space-between;
                    padding: 3px 0;

                    .ri {
                        color: #26a07b;
                    }
                }
            }

            .right {
                width: 50%;
                padding-left: 10px;
                color: #d5d5d5;
                font-size: 13px;
                box-sizing: border-box;

                .item {
                    display: flex;
                    justify-content: space-between;
                    padding: 3px 0;

                    .le {
                        color: #f5465d;
                    }
                }
            }
        }

        .make {
            width: 100vw;
            padding: 0 15px;
            height: 475px;
            background-color: #17171a;
            box-sizing: border-box;
            overflow: hidden;

            .title {
                display: flex;
                justify-content: space-between;
                align-items: center;
                width: 100%;
                font-size: 13px;
                color: #d5d5d5;
                margin-bottom: 10px;
            }

            .item {
                display: flex;
                justify-content: space-between;
                align-items: center;
                width: 100%;
                font-size: 13px;
                color: #d5d5d5;
            }
        }

    }

    .bottom {
        display: flex;
        justify-content: space-between;
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 82px;
        background-color: #2e323b;
        font-size: 17px;
        color: #fff;
        padding: 15px;
        box-sizing: border-box;

        .mairu {
            width: 48%;
            height: 43px;
            background-color: #2ebd85;
            text-align: center;
            line-height: 43px;
            border-radius: 8px;
        }

        .maichu {
            width: 48%;
            height: 43px;
            background-color: #f5465d;
            text-align: center;
            line-height: 43px;
            border-radius: 8px;
        }
    }
}
</style>